package com.example.apione.model;

import com.alibaba.fastjson2.JSONObject;
import com.example.apione.dao.WebInfoDao;
import com.example.apione.entity.WebInfo;
import com.example.apione.utils.ResponseResult;

/**
 * @author 尘落
 * @date 2023/2/25
 */
public class Webinfomodel {
    public static ResponseResult<WebInfo> getinfo(WebInfoDao webInfoDao){
        WebInfo data =webInfoDao.selectOne(null);
        return ResponseResult.ok(data);
    }
    public static String setinfo(WebInfoDao webInfoDao, JSONObject jsonObject){
        WebInfo webInfo=new WebInfo();
        webInfo.setTitle(jsonObject.getString("title"));
        webInfo.setSubtitle(jsonObject.getString("subtitle"));
        webInfo.setDomain(jsonObject.getString("domain"));
        webInfo.setKeywords(jsonObject.getString("keywords"));
        webInfo.setDesc(jsonObject.getString("desc"));
        webInfo.setIcp(jsonObject.getString("icp"));
        try {
            webInfoDao.updateById(webInfo);
            return "ok";
        }catch (Exception e){
            return "off";
        }


    }
}
